﻿#region Header
//************************************************************************************
// Name: IDao
// Description: Dao Interface
// Created On:  02-Aug-2011
// Created By:  Swathi
// Last Modified On:
// Last Modified By:
// Last Modified Reason:
//*************************************************************************************
#endregion Header
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Base.Common
{
    public interface IDao<T, TIdT>
    {
        T GetById(TIdT id, bool shouldLock);
        T GetSingle(Expression<Func<T, bool>> expression);
        List<T> GetAll();
        List<T> GetByExample(T exampleInstance, params string[] propertiesToExclude);
        T GetUniqueByExample(T exampleInstance, params string[] propertiesToExclude);
        T Save(T entity);
        T SaveOrUpdate(T entity);
        void Delete(T entity);
        void CommitChanges();
        PagedList<T> GetPaged(int pageIndex, int pageSize);
         IList<T> GetAll(Expression<Func<T, bool>> expression , int skip, int take);
         IEnumerable<T> GetAllFuture(Expression<Func<T, bool>> expression, int skip, int take);

        event EventHandler<EventArgs> Saved;
        void OnSaved(T entity, SaveAction action);
    }

    public enum SaveAction
    {
        /// <summary>
        /// Default. Nothing happened.
        /// </summary>
        None,
        /// <summary>
        /// It's a new object that has been inserted.
        /// </summary>
        Insert,
        /// <summary>
        /// It's an old object that has been updated.
        /// </summary>
        Update,
        /// <summary>
        /// The object was deleted.
        /// </summary>
        Delete
    }
}
